package TUILayer;
import java.util.Scanner;
import ModelLayer.*;
import ControlLayer.DVDCtr;
/**
 * User interface to the DVD controller
 * @author(kbh)
 * @version(2005.03.31)
 * (FEN): 2006.02.24: Comments translated into English
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 * (KBH): 2008.10.24: dvdmenu changed to If                   
 */

public class DvdUI
{
    private DVDCtr dvdCtr;//DVD UI must know the DVD controller 
    
    public DvdUI()
    {
        dvdCtr = new DVDCtr();
    }

    public void start()
    {        
        dvdMenu();
    }
    
    public void dvdMenu()
    {   
        boolean exit = false;
        while(!exit)
        {
            //show menu and return the user's choise
            int choise =   writeDVDMenu();
            if (choise == 1)
            {
                findDVD(); // Method to find a DVD in the collection.
            }
            else{if(choise == 2){
                   createDVD(); // Method to create a DVD and place it in the Collection.
                }
                else{
                    if(choise == 3){
                        createCopy(); // Creates a specimen of a given DVD.
                    }
                    else{
                        if(choise == 4){
                             removeDVD(); // Removes a DVD from the collection
                        }
                        else{
                            if(choise == 5){
                                listAllDvds(); // This method has not been made.
                            }
                            else{
                                exit = true;
                            }//end else
                        }//end else
                    }//end else
                }//end else
            }//end else
            
        }//end while
    }
    private int writeDVDMenu()
    {
           // creates an object keyboard to read data from the keyboard
            Scanner keyboard = new Scanner(System.in);
            System.out.println("\f *** DVD Menu ***");
            System.out.println(" (1) Show DVD information");
            System.out.println(" (2) Create DVD");
            System.out.println(" (3) Create DVD specimen");
            System.out.println(" (4) Delete DVD");
            System.out.println(" (5) Show current DVD list");
            System.out.println(" (6) Return");
            System.out.print("\n Make your choise: ");
            
            int choise = keyboard.nextInt();
            return choise;
    }
    private int inputDVDNo()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type DVD id: ");
        int no = keyboard.nextInt();
        return no;
    }
    
    private String inputTitle()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type DVD title: ");
        String title = keyboard.nextLine();
        return title;
    }
    private int inputCopyNo()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type the copy number: ");
        int no = keyboard.nextInt();
        return no;
    }

    private String inputArtist()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type the Artist: ");
        String title = keyboard.nextLine();
        return title;
    }
    
    private String inputReleaseDate()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type the Release date: ");
        String title = keyboard.nextLine();
        return title;
    }
    
    private void findDVD()
    {     
        int no = inputDVDNo();
        DVD dvd = dvdCtr.findDVD(no);
        System.out.println("Title: " + dvd.getTitel());
        System.out.println("Artist: " + dvd.getArtist());
        System.out.println("Release Date: " + dvd.getReleaseDate());
        pause();
    }
    
    private void createDVD()
    {
        int id = inputDVDNo();
        String title = inputTitle();
        String artist = inputArtist();
        String releaseDate = inputReleaseDate();
        dvdCtr.createDVD(id, title, artist, releaseDate);
    }
    
    private int inputSerialNr()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type the Serial Number: ");
        int title = keyboard.nextInt();
        return title;
    }
    
    private String inputBuyDate()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type the day of purchace: ");
        String title = keyboard.nextLine();
        return title;
    }
    
    private String inputBuyPrice()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type the Purchace price: ");
        String title = keyboard.nextLine();
        return title;
    }
    
    private void createCopy()
    {
        int dvdId = inputDVDNo();
        int serialNr = inputSerialNr();
        String buyDate = inputBuyDate();
        String buyPrice = inputBuyPrice();
        dvdCtr.createCopy(dvdId, serialNr, buyDate, buyPrice);
    }
    
    private void removeDVD()
    {
        int id = inputDVDNo();
        dvdCtr.removeDVD(id);
    }
    private void listAllDvds()
    {
    }
    
    private void pause()
    {
        Scanner keyboard = new Scanner(System.in);
        String vent = keyboard.nextLine();
    }
}